package com.blog.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserCategoryMapper {
    @Select("select category_id from tb_user_category where user_id = #{id}")
    List<Long> select(Long id);

    @Insert("insert into tb_user_category(user_id,category_id) values(#{currentId},#{cid})")
    void insert(@Param("cid") Long cid,@Param("currentId") Long currentId);
    @Select("select count(*) from tb_user_category where user_id = #{currentId} and category_id = #{cid}")
    Long selectByUidAndCid(@Param("cid") Long cid,@Param("currentId") Long currentId);

    @Select("SELECT count(*) FROM tb_user_category WHERE user_id = #{uid}")
    Long countCategory(Long uid);
}
